package com.gyy.Thermometry;

import com.gyy.sdk.HCNetSDK;
import com.sun.jna.ptr.IntByReference;


/**
 *
 * @Author sdk支持
 * @Date 2021/3/16 17:54
 */
public class ThreadGetOnceTempData {

    static HCNetSDK hCNetSDK = HCNetSDK.INSTANCE;

    /**
     * 手动获取测温规则温度信息
     *
     * 注意：调用手动获取测温规则温度信息之前需要确认已使能，可以在网页端->配置->测温->基本功能->开启测温功能，也可以调用NET_DVR_SetDVRConfig接口开启使能
     *
     * @param lUserID 用户登录句柄
     * @param RuleID 规则ID
     */
    public void threadGetOnceTempData(int lUserID, int RuleID) {
        HCNetSDK.NET_DVR_THERMOMETRYRULE_TEMPERATURE_INFO m_TherTemInfo = new HCNetSDK.NET_DVR_THERMOMETRYRULE_TEMPERATURE_INFO();
        m_TherTemInfo.write();
        IntByReference lpBytesReturned = new IntByReference(0);
        if (!hCNetSDK.NET_DVR_GetDVRConfig(lUserID, HCNetSDK.NET_DVR_GET_THERMOMETRYRULE_TEMPERATURE_INFO, RuleID, m_TherTemInfo.getPointer(), m_TherTemInfo.size(), lpBytesReturned)) {
            System.out.println("手动获取测温规则温度信息失败，错误号：" + hCNetSDK.NET_DVR_GetLastError());
        } else {
            m_TherTemInfo.read();
            System.out.println("手动获取测温规则温度信息成功!");

            System.out.println("最高温：" + m_TherTemInfo.fMaxTemperature + " 最低温：" + m_TherTemInfo.fMinTemperature + " 平均温：" + m_TherTemInfo.fAverageTemperature
                    + " 最高温点坐标：（" + m_TherTemInfo.struHighestPoint.fX + "," + m_TherTemInfo.struHighestPoint.fY + ")"
                    + " 最低温点坐标：（" + m_TherTemInfo.struLowestPoint.fX + "," + m_TherTemInfo.struLowestPoint.fY + ")");
        }
    }

}
